package SQLRotu;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class FileTest {

	public static void readByBytes(String fileName) throws InterruptedException{
    	File file = new File(fileName);  
        InputStream in = null;  
        try {  
        	System.out.println("以字节为单位读取文件内容，一次读多个字节：");  
            // 一次读多个字节  
            byte[] tempbytes = new byte[100];
            int byteread = 0;  
            in = new FileInputStream(file);
            Thread.sleep(1000*30);
            // 读入多个字节到字节数组中，byteread为一次读入的字节数  
            while ((byteread = in.read(tempbytes)) != -1) {  
                System.out.write(tempbytes, 0, byteread);  
            } 
        } catch (IOException e) {  
            e.printStackTrace();
            return;
        }finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e1) {
                	e1.printStackTrace();
                }  
            }  
        }
    }
	
	public static void main(String[] args) {
		try {
//			readByBytes("E://java//test.txt");
			System.gc();
			Thread.sleep(1000*50);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}
